
var obj = {
  "name": "yibo",
  "age": 23,
  "hobbies": ["滑板", "摩托", "跳舞", "唱歌"],
  "friends": [
      {
          "name": '肖战',
          "age": 29,
          "hobbies": ["拍戏"]
      }, {
          "name": '大张伟',
          "age": 35,
          "hobbies": ["唱歌", "吉他"]
      }
  ],
  "importance": {
      "borthday": "1997",
      "tiantian": 2017,
      "home": "Henan",
      "timeDay": 2000,
      "guanggao": ["yuemu", "haifeisi", "anmuxi"]
  }
};

/**
 * 深拷贝
 * @param {Object} obj 要拷贝的对象
 */
function deepClone(obj) {
  if (typeof obj !== 'object' || obj === null) return obj
  let newObj
  if (obj instanceof Array) {
    newObj = []
  } else {
    newObj = {}
  }
  for (let key in obj) {
    if (obj.hasOwnProperty(key))
      newObj[key] = deepClone(obj[key])
  }
  return newObj
}

const obj2 = deepClone(obj)
obj2.friends[0].name='尹正'
console.log(obj, obj2)